define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
	
	var Model = function(){
		this.callParent();
	};

	Model.prototype.backBtnClick = function(){
		this.comp("windowReceiver1").windowEnsure();
		this.getParentModel().goBackCommunity();
	};
	
	Model.prototype.getImageUrl = function(row) {
		return require.toUrl(row.val('imgUrl'));
	};
	
	Model.prototype.open = function(event) {	
		var row = event.bindingContext.$object;
//		var option = {
//		        type:"news",
//				title:row.val("title"),
//				content:row.val("content"),
//		};
		//justep.Shell.showPage("$UI/communityOto/community/channel/template.w",option);
		justep.Shell.showPage("$UI/communityOto/community/channel/template.w?id="+row.val('id'));
		
	};
	
	//加载最新资讯
	Model.prototype.lastestDataCustomRefresh = function(event){
	     this.getAndLoadNews("bf9dddf9ee8644dbb19fff5bca177e70", event);
	    
	};
	
	Model.prototype.getAndLoadNews = function(categoryId,event){
	    var id = JSON.parse(localStorage.getItem("userInfo")).data[2].id;
		var url = "http://www.xjzlhy.com:81/ex_community/a/api/community/getNewsByCategoryId?callback=?&category.id="+categoryId;
		$.getJSON(
				url,
				{
				  "office.id":id
				},
				function(data){
				    console.log("data",data);
					event.source.loadData(data.data);
				}			
		);
	
	};
	
	//加载新闻资讯
	Model.prototype.newsDataCustomRefresh = function(event){
		this.getAndLoadNews("90f11e024f214e5cb35b923ab42f5965", event);
	};
	
	//加载行业新闻
	Model.prototype.industryDataCustomRefresh = function(event){
	     this.getAndLoadNews("2c73954e3c4544ffb034aef4cd42816d", event);
		
	};
	
	
	Model.prototype.changeActiveStyle = function(event){
		$(".btn-link").removeClass("newTypeBorder");
		$(event.currentTarget).addClass("newTypeBorder");
		
	};
	
	
	Model.prototype.modelLoad = function(event){
		$(".btn-group .btn-link:first-child").addClass("newTypeBorder");

	};
	
	Model.prototype.onTouchStart = function(event){
	
	     $(event.currentTarget).addClass("touch");

	};
	
	
	
	Model.prototype.onTouchEnd = function(event){
		$(event.currentTarget).removeClass("touch");
	};
	
	
	
	
	
	Model.prototype.professionClick = function(event){
		this.changeActiveStyle(event);
		this.comp("industryList").refresh();
	};
	
	
	
	
	
	Model.prototype.newsClick = function(event){
		this.changeActiveStyle(event);
		this.comp("newsList").refresh();

	};
	
	
	
	
	
	return Model;
});